#ifndef _SCENE_H
#define _SCENE_H

#include <vector>

#include "Common.h"
#include "Material.h"
#include "Primitive.h"
#include "Sphere.h"
#include "Light.h"
#include "Camera.h"
#include "PinholeCamera.h"

namespace Pandora
{

	class CScene
	{
		int width;
		int height;

		float envRef;

		CCamera* camera;
	public:
		CScene() : width(0), height(0), camera(NULL){}
		CScene(int w, int h, CCamera* cam) : width(w), height(h), camera(cam){}
		CScene(CScene& s) : width(s.GetWidth()), height(s.GetHeight()), envRef(s.GetEnviromentRefraction()), materialContainer(s.materialContainer), primitiveContainer(s.primitiveContainer), lightContainer(s.lightContainer) 
		{
			switch(s.GetCamera()->GetType())
			{
			case PINHOLE:
				{
					camera = new CPinholeCamera(width, height);
					*camera = *s.GetCamera();
				}
			}
		}
		CScene(CScene* s) : width(s->GetWidth()), height(s->GetHeight()), envRef(s->GetEnviromentRefraction()), materialContainer(s->materialContainer), primitiveContainer(s->primitiveContainer), lightContainer(s->lightContainer)
		{
			switch(s->GetCamera()->GetType())
			{
			case PINHOLE:
				{
					camera = new CPinholeCamera(width, height);
					*camera = *s->GetCamera();
				}
			}
		}
		~CScene() { if(camera) { delete camera; camera = 0; }}

		std::vector<CMaterial*> materialContainer;
		std::vector<CPrimitive*> primitiveContainer;
		std::vector<CLight*> lightContainer;

		int GetWidth() const { return width; }
		int GetHeight() const { return height; }
		float GetEnviromentRefraction() const { return envRef; }
		CCamera* GetCamera() { return camera; }

		void SetWidth(int w) { width = w; }
		void SetHeight(int h) { height = h; }
		void SetEnviromentRefraction(float ref) { envRef = ref; }

		float RGBToDiff(float c) { return c * 0.01176470481; /* it's 3 * 1/255 */ }
		CColor RGBToDiff(float c1, float c2, float c3) { return CColor(c1, c2, c3) * 0.01176470481; /* it's 3 * 1/255 */ }
	};

}; //namespace Pandora

#endif /* _SCENE_H */